//
//  KATTableFooter.h
//  KATFramework
//
//  Created by Kantice on 16/7/19.
//  Copyright © 2016年 KatApp. All rights reserved.
//  列表底(基类)

#import <UIKit/UIKit.h>
#import "KATMacros.h"
#import "KATAppUtil.h"


#define TFOOTER_STATE_INIT -1
#define TFOOTER_STATE_READY 0
#define TFOOTER_STATE_PUSHING 1
#define TFOOTER_STATE_RELEASE 2
#define TFOOTER_STATE_LOADING 3
#define TFOOTER_STATE_FINISH 4



@class KATTableFooter;

///事件代理(给列表提供回调)
@protocol KATTableFooterDelegate <NSObject>

@optional

///开始加载
- (void)tableFooterDidStartLoad:(KATTableFooter *)footer;

@end



///状态代理(子类需要实现)
@protocol KATTableFooterStateDelegate <NSObject>

@required

///上推中，进度为1时完成
- (void)footerPushWithProgress:(float)progress;

///下拉完成
- (void)footerFinishPush;

///开始加载
- (void)footerStartLoad;

///完成加载
- (void)footerFinishLoad;

///加载完成后恢复
- (void)footerRestoreAfterLoad;

@end


@interface KATTableFooter : UIView
{
    dispatch_queue_t _footerQueue;
}


#pragma -mark 属性

///依附的scrollView
@property(nonatomic,assign) UIScrollView *scrollView;

///状态
@property(nonatomic,assign) int state;

///完整的下拉高度(默认为控件高度1.5倍)
@property(nonatomic,assign) float dragHeight;

///是否释放时才加载
@property(nonatomic,assign) BOOL isReleaseToLoad;

///加载完成后的隐藏时间(默认为0.8秒)
@property(nonatomic,assign) double animationFinishDuration;

///是否禁用
@property(nonatomic,assign,readonly) BOOL disabled;

///是否锁定(锁定后无法加载，防止冲突时使用)
@property(nonatomic,assign) BOOL locked;

///是否忽略冲突
@property(nonatomic,assign) BOOL ignoreConflicts;

///状态代理(给子类提供状态回调)
@property(nonatomic,assign) id<KATTableFooterStateDelegate> stateDelegate;

///事件代理
@property(nonatomic,assign) id<KATTableFooterDelegate> eventDelegate;


#pragma -mark 类方法

///获取实例
+ (instancetype)tableFooter;


#pragma -mark 对象方法

///初始化数据
- (void)initWithHeight:(float)height andScrollView:(UIScrollView *)scrollView;

///完成加载
- (void)finishLoad;

///直接加载
- (void)load;

///更新位置
- (void)updatePosition;

///禁用(不显示)
- (void)disableFooter;

///启用(显示)
- (void)enableFooter;


///释放内存
- (void)dealloc;


@end


